package com.xtaller.business.a.controller;


import com.xtaller.business.a.client.BClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Taller on 2017/8/6.
 */
@RefreshScope
@RestController
public class TestController {
    @Autowired
    EurekaDiscoveryClient discoveryClient;

    @Autowired
    private BClient bClient;

    @GetMapping(value = "/v1")
    public String printServiceA() {
        ServiceInstance serviceInstance = discoveryClient.getLocalServiceInstance();
        String msg = serviceInstance.getServiceId() + " (" + serviceInstance.getHost() + ":" + serviceInstance.getPort() + ")";
        return "a server print \n"+msg;
    }
    @GetMapping(value = "/v2")
    public String printServiceB() {
       return bClient.printServiceB();
    }
}
